Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add task_kwargs param to dbt_flow #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kiyanmair
Copy link

The functions which create Prefect tasks for all dbt resource types (_task_dbt_snapshot, _task_dbt_seed, and _task_dbt_run) all have optional task_kwargs parameters, but these don't seem to be used. It would be useful to be able to set these kwargs when creating a dbt flow, for example to specify retry behaviour.

This PR simply adds the task_kwargs parameter to dbt_flow and passes its value through to generate_tasks_dag. Within the latter, this PR supplies task_kwargs when creating all_tasks, which applies to the tasks corresponding to resource types only.

Resolves #42.

NOTE: I haven't tested this change yet. I'm also new to this repo and may have overlooked something.

@@ -11,6 +11,7 @@ def dbt_flow(
profile: Optional[DbtProfile] = None,
dag_options: Optional[DbtDagOptions] = None,
flow_kwargs: Optional[dict] = None,
task_kwargs: Optional[dict] = None,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that in tasks.py, Dict is imported from typing (along with List), while flow.py just uses dict. If this is an inconsistency, I'm happy to clean it up in this PR.

@@ -237,6 +239,7 @@ def generate_tasks_dag(
profile=profile,
dag_options=dag_options,
dbt_node=dbt_node,
task_kwargs=task_kwargs,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I've applied the same task_kwargs to all dbt tasks corresponding to resource types, but not those corresponding to dbt tests (below). However, I'm wondering if a more specific method of supplying task_kwargs is preferred, for example to specify different values for tests or even for different resource types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support prefect task retries
1 participant